//
//  LJUser.swift
//  LJWeibo
//
//  Created by Raymond on 15/12/21.
//  Copyright © 2015年 liu. All rights reserved.
//

import UIKit

class LJUser: NSObject {
    
    /// MARK: - 属性
    /// 用户UID
    var id: Int = 0
    
    /// 用户昵称
    var screen_name: String?
    
    ///用户头像地址（中图），50×50像素
    var profile_image_url: String?
    
    /// 认证类型, 没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
    var verified_type: Int = -1 {
        didSet{
           // 根据传入的认证类型赋予相应得图片
            switch  verified_type {
            case 0:
                varifiedImage = UIImage(named: "avatar_enterprise_vip")
            case 2,3,5:
                varifiedImage = UIImage(named: "avatar_vip")
            case 220:
                varifiedImage = UIImage(named: "avatar_grassroot")
            default:
                varifiedImage = nil
            }
        }
    }
    
    /// 会员等级
    var mbrank: Int = 0{
        didSet{
            if mbrank > 0 && mbrank <= 6 {
                 mbrankImage = UIImage(named: "common_icon_membership_level\(mbrank)")
            }else{
                // 清空图片
                mbrankImage = nil
            }
        }
    }
    
    /// 认证类型对应的图片
    var varifiedImage: UIImage?
    
    /// 会员等级对应的图片
    var mbrankImage: UIImage?
    
    /// MARK: - 字典转模型
    init(dict: [String : AnyObject]) {
        super.init()
        
        // KVC
        setValuesForKeysWithDictionary(dict)
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    /// MARK: - 打印
    override var description:String {
        let prop = ["id", "screen_name", "profile_image_url", "verified_type", "mbrank"]
        let dict = dictionaryWithValuesForKeys(prop)
        
        return "\n\t\t用户模型\(dict)"
    }
}
